<style>
    .panel-header, .panel-body {
        border-width: 0px;
    }

    .datagrid, .combo-p {
        border: solid 1px #D4D4D4;
    }

    .panel-title {
        cursor: pointer
    }

    .inlineblock {
        margin-top: 10px;
    }

    .inlineblock div {
        display: inline-block;
    }

    .inlineblock div label {
        display: inline-block;
        top: 5px;
    }

    .newform {
        width: 70%;
    }

    .editform {
        width: 70%;
    }

    .searchClass {
        margin-left: 5%;
        margin-top: 1%;
    }

    .searchClass label {        width: 9%;
        font-weight: bold;
        text-align: center;
    }

    #Search {
        float: right;
        margin-right: 4%;
        width: 14%;
    }
    .file {
        position: relative;
        display: inline-block;
        background: #D0EEFF;
        border: 1px solid #99D3F5;
        border-radius: 4px;
        padding: 4px 12px;
        overflow: hidden;
        color: #1E88C7;
        text-decoration: none;
        text-indent: 0;
        line-height: 20px;
    }
    .file input {
        position: absolute;
        font-size: 100px;
        right: 0;
        top: 0;
        opacity: 0;
    }
    .file:hover {
        background: #AADFFD;
        border-color: #78C3F3;
        color: #004974;
        text-decoration: none;
    }

    .fileImg {
        position: relative;
        display: inline-block;
        background: #D0EEFF;
        border: 1px solid #99D3F5;
        border-radius: 4px;
        padding: 4px 12px;
        overflow: hidden;
        color: #1E88C7;
        text-decoration: none;
        text-indent: 0;
        line-height: 20px;
    }
    .fileImg input {
        position: absolute;
        font-size: 100px;
        right: 0;
        top: 0;
        opacity: 0;
    }
    .fileImg:hover {
        background: #AADFFD;
        border-color: #78C3F3;
        color: #004974;
        text-decoration: none;
    }

</style>
<div class="row">
    <div id="breadcrumb" class="col-xs-12" style="margin-bottom: 10px">
        <a href="#" class="show-sidebar"> <i class="fa fa-bars"></i>
        </a>
        <ol class="breadcrumb pull-left">
            <li><a href="#">书籍管理</a></li>
            <li><a href="#">书籍管理</a></li>
        </ol>
    </div>
</div>
<div class="row">
    <div class="col-xs-12">
        <div class="box">
            <div class="box-header">
                <div class="box-name">
                    <i class="fa fa-clipboard"></i> <span>书籍管理</span>
                </div>
                <div class="box-icons">
                    <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
                    </a> <a class="expand-link"> <i class="fa fa-expand"></i>
                </a> <a class="close-link"> <i class="fa fa-times"></i>
                </a>
                </div>
                <div class="no-move"></div>
            </div>
            <div class="box-content table-responsive" style="padding-top: 15px">

                <div class="panel panel-default" style="border: 1px solid #CCC; height: auto;">
                    <div class="panel-heading" role="tab" id="headingOne">
                        <h4 class="panel-title" data-toggle="collapse" data-target="#collapseForAdd">
                            功能面板 <span class="fa fa-chevron-down" style="float: right"></span>
                        </h4>
                    </div>

                    <div id="collapseForAdd" class="panel-collapse collapse in" role="tabpanel"
                         aria-labelledby="headingOne">
                        <div class="panel-body">
                            <div class="container-fluid" style="margin-top: 10px;">
                                <!--操作-->
                                <div id="operationpanel" class="col-xs-12">
                                    <div class="col-xs-12 btn-menu-top-minus" style="margin-top:5px;">
                                        <button class="btn btn-primary btn-sm addbook">
                                            <i class="fa fa-file-o"></i> 发布书籍
                                        </button>
                                        <!--<button class="btn btn-primary btn-sm editbook">-->
                                            <!--<i class="fa fa-file-text"></i>修改书籍-->
                                        <!--</button>-->
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>

                <!--主信息面板 S-->
                <div class="panel panel-default" style="border: 1px solid #CCC;">
                    <div class="panel-heading" role="tab" id="headingTwo">
                        <h4 class="panel-title" data-toggle="collapse" data-target="#collapseForCourseTable">
                            公告基础信息<span class="fa fa-chevron-down" style="float: right"></span>
                        </h4>
                    </div>
                    <div id="collapseForCourseTable" class="panel-collapse collapse in" role="tabpanel"
                         aria-labelledby="headingTwo">
                        <div class="panel-body" style="overflow: hidden;">
                            <!--搜索区域-->
                            <div class="searchClass row">
                                <div class="col-xs-12">
                                    <label>关键字</label>
                                    <input class="SearchForm form-control" placeholder="书籍名称" type="text" id="keyword"/>
                                    <label>发布状态</label>
                                    <select class="SearchForm form-control" id="book_status" name="book_status">
                                        <option value="">不限</option>
                                        <option value="1">发布</option>
                                        <option value="2">未发布</option>
                                    </select>
                                    <label style="margin-top:20px">发布时间</label>
                                    <input style="width:16%"class="SearchForm form-control" type="text" placeholder="开始时间" id="start" onclick="WdatePicker({lang:'zh-cn',dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
                                    <input style="width:16%"class="SearchForm form-control" type="text" placeholder="结束时间" id="end" onclick="WdatePicker({lang:'zh-cn',dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>

                                </div>
                            </div>
                            <br/>
                            <button id="Search" class="btn btn-primary btn-xs" style="height: 30px;margin-left: 30px">
                                <i class="fa fa-search"></i>&nbsp;&nbsp;搜索
                            </button>
                            <button id="Reset" class="btn btn-primary btn-sm" style="width:120px;float: right;">
                                清空查询条件
                            </button>
                        </div>
                        <table class="table table-bordered " id="datatable_noticeinfo" data-size="15" style="width: 100%">

                        </table>
                    </div>
                </div>
                <!--主信息面板 E-->
            </div>
        </div>
    </div>
</div>
<script src="static/js/super/book.js"></script>
<script>
    function UpdateCatalog(c) {
        var project_id = c.name;
        window.location.href = "super#personal_settings?book_id="+project_id;
        location.reload();
    }
    /***
     * 审核通过
     * */
//    function agreeCourse(c) {
//        var cid = c.name;
//        if(confirm('确认审核通过此课程吗？')){
//            $.ajax({
//                url: 'admin/Study/updateLife',
//                data: 'cid=' + cid,
//                type: 'POST',
//                dataType: 'JSON',
//                success: function (returnData) {
//                    if (returnData.status == 0) {
//                        $.TeachDialog({
//                            content: returnData.msg
//                        });
//                    } else {
//
//                        $.TeachDialog({
//                            content: returnData.msg,
//                            showCloseButton: false,
//                        });
//                        $('#datatable_noticeinfo').datagrid('reload');
//
//                    }
//                },
//                error: function () {
//                    $.TeachDialog({
//                        content: '系统异常，请联系管理员',
//                    });
//                },
//
//            });
//        }
//    }
    /**
     * 审核不通过
     * @param c
     */
//    function refuseCourse(c) {
//        var cid = c.name;
//        if(confirm('确认审核不通过此课程吗？')){
//            $.ajax({
//                url: 'admin/Study/refuseLife',
//                data: 'cid=' + cid,
//                type: 'POST',
//                dataType: 'JSON',
//                success: function (returnData) {
//                    if (returnData.status == 0) {
//                        $.TeachDialog({
//                            content: returnData.msg
//                        });
//                    } else {
//
//                        $.TeachDialog({
//                            content: returnData.msg,
//                            showCloseButton: false,
//                        });
//                        $('#datatable_noticeinfo').datagrid('reload');
//
//                    }
//                },
//                error: function () {
//                    $.TeachDialog({
//                        content: '系统异常，请联系管理员',
//                    });
//                },
//
//            });
//        }
//    }
    /**
     * 发布
     */
    function ReleaseInfo(c) {
        var cid = c.name;
        if(confirm('确认发布此书籍信息吗？')){
            $.ajax({
                url: 'super/Book/Confirmation',
                data: 'cid=' + cid,
                type: 'POST',
                dataType: 'JSON',
                success: function (returnData) {
                    if (returnData.status == 0) {
                        $.TeachDialog({
                            content: returnData.msg
                        });
                    } else {

                        $.TeachDialog({
                            content: returnData.msg,
                            showCloseButton: false,
                        });
                        $('#datatable_noticeinfo').datagrid('reload');

                    }
                },
                error: function () {
                    $.TeachDialog({
                        content: '系统异常，请联系管理员',
                    });
                },

            });
        }
    }

    /***
     * 取消发布
     */
    function QxReleaseInfo(c) {
        var cid = c.name;
        if(confirm('确认取消发布此书籍信息吗？')){
            $.ajax({
                url: 'super/Book/QxConfirmation',
                data: 'cid=' + cid,
                type: 'POST',
                dataType: 'JSON',
                success: function (returnData) {
                    if (returnData.status == 0) {
                        $.TeachDialog({
                            content: returnData.msg
                        });
                    } else {

                        $.TeachDialog({
                            content: returnData.msg,
                            showCloseButton: false,
                        });
                        $('#datatable_noticeinfo').datagrid('reload');

                    }
                },
                error: function () {
                    $.TeachDialog({
                        content: '系统异常，请联系管理员',
                    });
                },

            });
        }
    }

    /**
     * 删除
     */
    function deleteInfo(c) {
        var cid = c.name;
        if(confirm('确认删除此书籍信息吗？')){
            $.ajax({
                url: 'super/Book/delConfirmation',
                data: 'cid=' + cid,
                type: 'POST',
                dataType: 'JSON',
                success: function (returnData) {
                    if (returnData.status == 0) {
                        $.TeachDialog({
                            content: returnData.msg
                        });
                    } else {

                        $.TeachDialog({
                            content: returnData.msg,
                            showCloseButton: false,
                        });
                        $('#datatable_noticeinfo').datagrid('reload');

                    }
                },
                error: function () {
                    $.TeachDialog({
                        content: '系统异常，请联系管理员',
                    });
                },

            });
        }
    }
    /**
     * 修改
     */
    function updateInfo(c) {
        var book_id = c.name;
        var content = "";

        $.ajax({
            url: 'super/Book/updateBook',
            data: "nid=" + book_id,
            type: 'POST',
            dataType: 'HTML',//返回的数据类型
            success: function (updatemodalhtml) {
                content = updatemodalhtml;
                //弹出修改框
                $.TeachDialog({
                    title: '修改书籍信息',
                    content: content,
                    showCloseButton: true,
                    showCloseButtonName: '关闭',
                    otherButtons: ['保存'],
                    otherButtonStyles: ['btn-primary'],
                    clickButton: function (sender, modal, index) {
                        var formData = new FormData($("#updateForm" )[0]);
                        var book_len = $("input[name='book_name']").val().length;
                        if(book_len>30){
                            layer.open({
                                content: '书籍名称超过30个字节',
                            });
                            return false;
                        }
                        $.ajax({
                            url: 'super/Book/updateBookInfo',
                            data: formData,
                            type: 'POST',
                            dataType: 'JSON',
                            async: false,
                            cache: false,
                            contentType: false,
                            processData: false,
                            success: function (returnData) {
                                if (returnData.status == 0) {
                                    layer.open({
                                        content: returnData.msg
                                    });
                                } else {
                                    modal.modal('hide');
                                    $('#datatable_noticeinfo').datagrid('reload');
                                }
                            },
                            error: function () {
                                $.TeachDialog({
                                    content: '系统异常，请联系管理员'
                                });
                            },

                        });

                    },
                });
            },
            error: function () {
                $.TeachDialog({
                    content: '系统异常，请联系管理员'
                });
                return;
            }
        });
    }

</script>
